package com.goodving.guli.bt.model;

import android.content.Context;
import android.os.AsyncTask;
import android.text.TextUtils;

import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.C1468p;
import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.dataprocess.DaySportData;
import com.goodving.guli.bt.dataprocess.DaySportData.Summary;
import com.goodving.guli.bt.dataprocess.SleepInfo;
import com.goodving.guli.bt.dataprocess.SportDay;
import com.goodving.guli.bt.dataprocess.StepsInfo;
import com.goodving.guli.bt.dataprocess.SummaryEmpty;
import com.goodving.guli.bt.dataprocess.SummaryEntity;
import com.goodving.guli.bt.dataprocess.UserInfo;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.database.C0855b;
import com.goodving.guli.model.DeviceSource;
import com.goodving.guli.model.Keeper;
import com.goodving.guli.model.SyncedServerDataInfo;
import com.goodving.guli.model.UserTotalSportData;
import com.goodving.guli.view.C3657a;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import cn.com.smartdevices.bracelet.chart.util.ChartData;
import cn.com.smartdevices.bracelet.config.C0886a;

/**
 * Created by john on 2015/12/7.
 */
public class DataManager implements C0881a { // C1448m
    public static final int f7346a = 4;
    private static final String f7347b = "DataManager";
    private static final boolean f7348c = false;
    private static final int f7349f = 7;
    private static final int f7350g = 0;
    private static final int f7351h = 1;
    private static final int f7352i = 2;
    private static final int f7353j = 3;
    private static final int f7354k = 5;
    private static final int f7355l = 6;
    private static final String f7356m = "2014-09-30";
    private static DataManager f7357v;
    private static Context f7358x;
    private ReportData f7359A;
    private SportDay f7360d;
    private boolean f7361e;
    private C0855b f7362n;
    private final ConcurrentHashMap<String, DaySportData> f7363o;
    private final ConcurrentHashMap<String, Summary> f7364p;
    private SportDay f7365q;
    private SportDay f7366r;
    private SportDay f7367s;
    private SportDay f7368t;
    private SportDay f7369u;
    private SyncedServerDataInfo f7370w;
    private SportDay f7371y;
    private SportDay f7372z;

    static {
        f7357v = null;
        f7358x = null;
    }

    private DataManager(Context context) {
        this.f7361e = f7348c;
//        this.f7362n = null;
        this.f7363o = new ConcurrentHashMap();
        this.f7364p = new ConcurrentHashMap();
        this.f7365q = new SportDay();
        this.f7366r = new SportDay();
        this.f7367s = new SportDay();
        this.f7368t = null;
        this.f7369u = null;
        this.f7370w = null;
        this.f7371y = null;
        this.f7372z = SportDay.fromString(f7356m);
        f7358x = context.getApplicationContext();
        this.f7362n = com.goodving.guli.database.C0855b.m8954a(f7358x);
        m12217c();
    }

    private int m12178a(String str, String str2) {
        return ((int) ((SportDay.toCalenday(str2).getTime().getTime() - SportDay.toCalenday(str).getTime().getTime()) / 86400000)) + f7351h;
    }

    public static DataManager m12179a() {
        return f7357v;
    }

    private ReportData m12180a(ReportData reportData, SportDay sportDay, SportDay sportDay2) {
        int a = m12178a(sportDay.toString(), sportDay2.toString());
        if (a >= 0) {
            reportData.clearPartSportData();
            int i = f7350g;
            int i2 = f7350g;
            int i3 = f7350g;
            int i4 = reportData.maxContinueDays;
            int i5 = f7350g;
            GuliLog.tracePrintInfo(f7347b, "normal maxDays = " + i4);
            reportData.setContinueDays(m12178a(reportData.timeFrom, reportData.timeTo));
            int i6 = f7350g;
            while (i6 < a) {
                int i7;
                SportDay addDay = sportDay.addDay(i6);
                Summary b = m12210b(addDay);
                GuliLog.tracePrintInfo(f7347b, "temp day:" + addDay + ", steps =" + b.getSteps() + ", goal = " + b.getDayStepGoal() + ", reach: " + (b.getSteps() >= b.getDayStepGoal() ? true : f7348c));
                int i8;
                if (b.getSteps() >= b.getDayStepGoal()) {
                    i3 += f7351h;
                    if (i3 <= i4) {
                        i7 = i4;
                    } else if ((this.f7361e && (addDay.isToday() || addDay.isYesterday())) || i5 == f7353j) {
                        i7 = f7350g;
                        reportData.maxDateStr = C3657a.f18328f;
                        GuliLog.tracePrintInfo(f7347b, "set maxDays to 0 because it's in current continue process, not making history! ");
                    } else {
                        reportData.maxDateStr = addDay.toString();
                        GuliLog.tracePrintInfo(f7347b, "find new maxDays = " + i3 + " date = " + reportData.maxDateStr);
                        i7 = i3;
                    }
                    i5 = i2 + f7351h;
                    if (i5 % f7349f != 0 || i5 < f7349f) {
                        i4 = f7351h;
                    } else {
                        i += f7351h;
                        GuliLog.tracePrintInfo(f7347b, "skips + 1 = " + i + ", goalDaysTemp = " + i5);
                        i4 = f7352i;
                    }
                    if (addDay.isToday()) {
                        reportData.todayComplete = f7351h;
                    }
                    reportData.calories += b.getStepCalories();
                    reportData.steps += b.getSteps();
                    reportData.distance += b.getStepDistance();
                    reportData.runDistance += b.getStepRunDistance();
                    if (TextUtils.isEmpty(reportData.timeFrom)) {
                        reportData.timeFrom = addDay.toString();
                        i8 = i5;
                        i5 = i;
                        i = i8;
                    } else {
                        i8 = i5;
                        i5 = i;
                        i = i8;
                    }
                } else if (m12208a(addDay)) {
                    if (!addDay.isToday()) {
                        if (!m12190j(addDay)) {
                            GuliLog.tracePrintInfo(f7347b, "stop of manual algorithm in " + addDay.toString());
                            i7 = (!addDay.isYesterday() || i <= 0) ? f7350g : f7355l;
                            reportData.clearPartSportData();
                            i3 = f7350g;
                        } else if (i > 0) {
                            i--;
                            i7 = f7353j;
                            GuliLog.tracePrintInfo(f7347b, "server used skips at " + addDay + "....... left skips = " + i);
                        } else {
                            GuliLog.m12370d(f7347b, "server and local lazy different, local available skips =" + i);
                            i7 = i5;
                        }
                        i8 = i7;
                        i7 = i4;
                        i4 = i8;
                        i5 = i;
                        i = f7350g;
                    } else if (i > 0) {
                        if (m12190j(addDay)) {
                            i--;
                            i7 = f7354k;
                            GuliLog.tracePrintInfo(f7347b, "server used skips today ......... left skips = " + i);
                        } else {
                            i7 = f7346a;
                        }
                        GuliLog.tracePrintInfo(f7347b, "to show tips .........skips = " + i);
                        i5 = i;
                        i = i2;
                        i8 = i4;
                        i4 = i7;
                        i7 = i8;
                    } else {
                        GuliLog.tracePrintInfo(f7347b, "algo 2, failed today, continue to show previous record.........");
                        i7 = i4;
                        i4 = i5;
                        i5 = i;
                        i = i2;
                    }
                } else if (addDay.isToday()) {
                    i7 = i4;
                    i4 = i5;
                    i5 = i;
                    i = i2;
                } else if (i > 0) {
                    i5 = i - 1;
                    i = f7350g;
                    GuliLog.tracePrintInfo(f7347b, "skips - 1 = " + i5);
                    if (addDay.offsetDay(new SportDay()) == -1) {
                        i7 = i4;
                        i4 = f7353j;
                    } else {
                        i7 = i4;
                        i4 = f7351h;
                    }
                } else {
                    i3 = f7350g;
                    reportData.clearPartSportData();
                    i7 = i4;
                    i4 = f7350g;
                    i5 = i;
                    i = f7350g;
                }
                i6 += f7351h;
                i2 = i;
                i = i5;
                i5 = i4;
                i4 = i7;
            }
            GuliLog.tracePrintInfo(f7347b, "Status = " + i5 + ", reachGoalDays = " + i3 + ", skips = " + i);
            reportData.maxContinueDays = i4;
            reportData.setContinueDays(i3);
            reportData.skips = i;
            reportData.continueStatus = i5;
            GuliLog.tracePrintInfo(f7347b, "get report data  = " + reportData);
        }
        return reportData;
    }

    public static void m12181a(Context context) {
        if (f7357v == null) {
            f7357v = new DataManager(context);
        }
    }

    private void m12182a(Context context, int i, int i2) {
        Object obj = f7351h;
        if (i != i2 && context != null) {
            Object obj2 = i2 - i < 0 ? f7351h : f7350g;
            if (i2 - i <= 0) {
                obj = f7350g;
            }
            if (obj2 != null) {
                C0668a.m8127a(context, C0668a.em, Math.abs(i2 - i));
            } else if (obj != null) {
                C0668a.m8127a(context, C0668a.en, Math.abs(i2 - i));
            }
        }
    }

    private void m12183a(SummaryEntity summaryEntity, JSONObject jSONObject) {
        long j;
        try {
            JSONObject jSONObject2 = jSONObject.getJSONObject("steps_info");
            JSONObject jSONObject3 = jSONObject.getJSONObject("sleep_info");

            summaryEntity.setSteps(jSONObject2.optInt("steps"));
            summaryEntity.setStepDistance(jSONObject2.optInt("distance"));
            summaryEntity.setStepCalories(jSONObject2.optInt("calories"));
            summaryEntity.setStepWalkDistance(summaryEntity.getStepDistance());
            summaryEntity.setStepWalkCalories(summaryEntity.getStepCalories());
            summaryEntity.setStepWalkDuration(jSONObject2.optInt("walk_time"));
            summaryEntity.setStepRunDuration(jSONObject2.optInt("run_time"));
            summaryEntity.setStepDuration(summaryEntity.getStepWalkDuration() + summaryEntity.getStepRunDuration());
            summaryEntity.setSleep(jSONObject3.optInt("sleep_minutes"));
            summaryEntity.setSleepDeepTime(jSONObject3.optInt("nrem_minutes"));
            summaryEntity.setSleepShallowTime(jSONObject3.optInt("rem_minutes"));
            try {
                j = jSONObject3.getLong("start_date");
            } catch (Exception e) {
                e.printStackTrace();
                j = Date.parse(jSONObject3.getString("start_date"));
            }
            summaryEntity.setSleepStartTime(j);
            try {
                j = jSONObject3.getLong("stop_date");
            } catch (Exception e2) {
                e2.printStackTrace();
                j = Date.parse(jSONObject3.getString("stop_date"));
            }
            summaryEntity.setSleepRiseTime(j);
            summaryEntity.setSleepWakeTime(jSONObject3.optInt("awake_minutes"));
            jSONObject2 = jSONObject.optJSONObject("daysportgoal_info");
            if (jSONObject2 != null) {
                summaryEntity.setDayStepGoal(jSONObject2.optInt("goalStepsCount"));
            }
        } catch (JSONException e) {
            //TBD
        }
    }

    private void m12184a(SummaryEntity summaryEntity, JSONObject jSONObject, int i) {
        try {
            JSONObject jSONObject2 = jSONObject.getJSONObject(StepsInfo.KEY_STEP_INFO);
            JSONObject jSONObject3 = jSONObject.getJSONObject(SleepInfo.KEY_SLEEP_INFO);
            summaryEntity.setSteps(jSONObject2.optInt(StepsInfo.KEY_STEPS));
            summaryEntity.setStepDistance(jSONObject2.optInt(StepsInfo.KEY_DISTANCE));
            summaryEntity.setStepCalories(jSONObject2.optInt(StepsInfo.KEY_CALORIES));
            summaryEntity.setStepWalkDuration(jSONObject2.optInt(StepsInfo.KEY_STEP_WALK_TIME));
            summaryEntity.setStepRunDuration(jSONObject2.optInt(StepsInfo.KEY_STEP_RUN_TIME));
            summaryEntity.setStepDuration(summaryEntity.getStepWalkDuration() + summaryEntity.getStepRunDuration());
            summaryEntity.setStepRunDistance(jSONObject2.optInt(StepsInfo.KEY_STEP_RUN_DISTANCE));
            summaryEntity.setStepWalkDistance(summaryEntity.getStepDistance() - summaryEntity.getStepRunDistance());
            summaryEntity.setStepRunCalories(jSONObject2.optInt(StepsInfo.KEY_STEP_RUN_CALORIES));
            summaryEntity.setStepWalkCalories(summaryEntity.getStepCalories() - summaryEntity.getStepRunCalories());
            if (i > f7352i) {
                summaryEntity.setDayStepGoal(jSONObject.optInt("goal"));
            } else if (!jSONObject.isNull("daysportgoal_info")) {
                summaryEntity.setDayStepGoal(jSONObject.optInt("daysportgoal_info"));
            }
            if (jSONObject3 != null) {
                int optInt = jSONObject3.optInt(SleepInfo.KEY_DEEP_MINUTES);
                int optInt2 = jSONObject3.optInt(SleepInfo.KEY_LIGHT_MINUTES);
                if (i == f7351h) {
                    summaryEntity.setSleepDeepTime(optInt2);
                    summaryEntity.setSleepShallowTime(optInt);
                } else {
                    summaryEntity.setSleepDeepTime(optInt);
                    summaryEntity.setSleepShallowTime(optInt2);
                }
                summaryEntity.setSleep(optInt + optInt2);
                summaryEntity.setSleepWakeTime(jSONObject3.optInt(SleepInfo.KEY_AWAKE_MINUTES));
                summaryEntity.setSleepStartTime(jSONObject3.getLong(SleepInfo.KEY_START_DATE) * 1000);
                summaryEntity.setSleepRiseTime(jSONObject3.getLong(SleepInfo.KEY_END_DATE) * 1000);
                summaryEntity.setUserSleepStart(jSONObject3.optInt(SleepInfo.KEY_USER_SLEEP_START, Integer.MIN_VALUE));
                summaryEntity.setUserSleepEnd(jSONObject3.optInt(SleepInfo.KEY_USER_SLEEP_END, Integer.MIN_VALUE));
            }
        } catch (JSONException e) {
            //TBD
        }
    }

    private void m12185a(DaySportData daySportData, DaySportData daySportData2, DaySportData daySportData3) {
        PersonInfo readPersonInfo = Keeper.readPersonInfo();
        UserSleepModify a = daySportData2 != null ? ChartData.m8731a().m8772a(daySportData2.getSportDay()) : null;
        if (daySportData3 != null) {
            ChartData.m8731a().m8772a(daySportData3.getSportDay());
        }
        UserInfo userInfo = new UserInfo();
        userInfo.gender = readPersonInfo.gender;
        userInfo.weight = Utils.m8085l();
        userInfo.height = readPersonInfo.height;
        userInfo.goal = readPersonInfo.getDaySportGoalSteps();
//        DataAnalysis.dataPostProcess(userInfo, daySportData, daySportData2, daySportData3, a, null, daySportData == null ? null : this.f7362n.m8980c(daySportData.getKey(), m12241t()), daySportData2 == null ? null : this.f7362n.m8980c(daySportData2.getKey(), m12241t()));
    }

    private boolean m12186a(SportDay sportDay, Summary summary) {
        Calendar instance = Calendar.getInstance();
        instance.setTimeInMillis(summary.getSleepStartTime());
        int i = instance.get(Calendar.DAY_OF_YEAR);
        int i2 = instance.get(Calendar.HOUR_OF_DAY);
        int i3 = sportDay.getCalendar().get(Calendar.DAY_OF_YEAR);
        GuliLog.tracePrintInfo(f7347b, "sleepDay: " + i + "; caclDay: " + i3 + "; sleep time:" + new SimpleDateFormat("HH:mm:ss").format(Long.valueOf(instance.getTimeInMillis())));
        return (i2 >= 23 || i == i3) ? f7348c : true;
    }

    private ReportData m12187b(SportDay sportDay, SportDay sportDay2) {
        ReportData reportData = new ReportData();
        reportData.setTimeTo(sportDay2.getKey());
        reportData.setTimeFrom(sportDay.getKey());
        while (sportDay2.compare(sportDay) >= 0) {
            Summary b = m12210b(sportDay2);
            if (b != null && b.getSteps() > 0) {
                reportData.distance += b.getStepDistance();
                reportData.runDistance += b.getStepRunDistance();
                reportData.calories += b.getStepCalories();
                reportData.steps += b.getSteps();
                if (b.getSteps() > reportData.maxDateStep) {
                    reportData.maxDateStep = b.getSteps();
                    reportData.maxDateStr = sportDay2.getKey();
                }
            }
            GuliLog.tracePrintInfo(f7347b, "getReportData: stop=" + sportDay2 + " distance = " + reportData.distance + ", startday = " + sportDay);
            sportDay2 = sportDay2.addDay(-1);
        }
        return reportData;
    }

    private void m12188b(C1495q c1495q) {
        long currentTimeMillis = System.currentTimeMillis();
        GuliLog.tracePrintInfo(f7347b, "in loadNetData");
        if (Utils.m8084k(f7358x)) {
            LoginData f = C0886a.m9071f(f7358x);
            String d = C0886a.m9069d(f7358x);
            GuliLog.tracePrintInfo(f7347b, "in loadNetData  deviceId = " + d);
//            WebAPI.m11608a(f, d, c1495q, (int) f7353j, new C1467o(this, c1495q));
            GuliLog.tracePrintInfo(f7347b, "out loadNetData:" + (System.currentTimeMillis() - currentTimeMillis) + "ms");
            return;
        }
        GuliLog.m12370d(f7347b, "isNetworkConnected:false");
    }

    private ReportData m12189c(SportDay sportDay, SportDay sportDay2) {
        ArrayList arrayList = new ArrayList();
        ReportData reportData = null;
        while (sportDay2.compare(sportDay) >= 0) {
            Summary b = m12210b(sportDay2);
            if (b.getDayStepGoal() <= b.getSteps()) {
                if (reportData == null) {
                    reportData = new ReportData();
                    arrayList.add(reportData);
//                    reportData.type = ShareListDelegateActivity.SHARE_TYPE_CONTIUE_REACH_GOAL;
                    reportData.timeTo = sportDay2.getKey();
                }
                reportData.timeFrom = sportDay2.getKey();
                reportData.calories += b.getStepCalories();
                reportData.steps += b.getSteps();
                reportData.distance += b.getStepDistance();
                reportData.runDistance = b.getStepRunDistance() + reportData.runDistance;
            } else {
                reportData = null;
            }
            sportDay2 = sportDay2.addDay(-1);
        }
        if (arrayList.size() == 0) {
            return new ReportData();
        }
        reportData = (ReportData) arrayList.get(f7350g);
        Calendar instance = Calendar.getInstance();
        instance.add(f7355l, -1);
        Summary b2 = m12210b(new SportDay(instance));
        if (b2.getSteps() >= b2.getDayStepGoal()) {
            this.f7361e = true;
        }
        Iterator it = arrayList.iterator();
        int i = f7350g;
        while (it.hasNext()) {
            ReportData reportData2 = (ReportData) it.next();
            GuliLog.tracePrintInfo(f7347b, reportData2.timeFrom + "--->" + reportData2.timeTo);
            int a = m12178a(reportData2.timeFrom, reportData2.timeTo);
            boolean z = ((SportDay.fromString(reportData2.timeTo).isToday() || SportDay.fromString(reportData2.timeTo).isYesterday()) && this.f7361e) ? true : false;
            if (a >= f7352i && a > i && !z) {
                GuliLog.m12370d(f7347b, "Found days max: " + a + ", yesterdayReachGoal = " + this.f7361e + ", timeTo = " + reportData2.timeTo);
                reportData.maxDateStr = reportData2.timeTo.toString();
                i = a;
            }
            SportDay fromString = SportDay.fromString(f7356m);
            int a2 = m12178a(reportData2.timeFrom, fromString.toString());
            a = m12178a(fromString.toString(), reportData2.timeTo);
            if (a2 >= 0 && a >= 0) {
                this.f7372z = SportDay.fromString(reportData2.timeFrom);
                GuliLog.tracePrintInfo(f7347b, "Calc startSkipDay = " + this.f7372z + ", lastestRd.timeFrom = " + reportData.timeFrom + ", lastestRd.timeTo = " + reportData.timeTo);
            }
        }
        reportData.maxContinueDays = i;
        return reportData;
    }

    private boolean m12190j(SportDay sportDay) {
        ArrayList d = Utils.m8060d();
        if (d == null) {
            return f7348c;
        }
        Iterator it = d.iterator();
        while (it.hasNext()) {
            if (((String) it.next()).equals(sportDay.toString())) {
                return true;
            }
        }
        return f7348c;
    }

    private int m12191k(SportDay sportDay) {
        DaySportData h;
        DaySportData h2;
        int i = f7351h;
        SportDay addDay = sportDay.addDay(-1);
        SportDay addDay2 = sportDay.addDay(f7351h);
        if (!this.f7370w.isSynced()) {
            m12188b(new C1495q());
        }
        if (!this.f7363o.containsKey(sportDay.getKey())) {
            h = m12228h(sportDay);
            if (h != null) {
                m12206a(h);
            }
        }
        if (!((addDay.compare(this.f7365q) >= 0 ? f7351h : f7350g) == 0 || this.f7363o.containsKey(addDay.getKey()))) {
            h = m12228h(addDay);
            if (h != null) {
                m12206a(h);
            }
        }
        if (addDay2.compare(m9055l()) > 0) {
            i = f7350g;
        }
        if (!(i == 0 || this.f7363o.containsKey(addDay2.getKey()))) {
            h2 = m12228h(addDay2);
            if (h2 != null) {
                m12206a(h2);
            }
        }
        h2 = m9052g(sportDay);
        h = m9052g(addDay);
        DaySportData g = m9052g(addDay2);
        if (h2 != null && h2.isNeedPostProcess()) {
            m12185a(h, h2, g);
        }
        return f7350g;
    }

    private void m12193v() {
        Calendar instance = Calendar.getInstance();
        long readLastCaclMedalTime = Keeper.readLastCaclMedalTime();
        if (readLastCaclMedalTime != 0) {
            instance.setTimeInMillis(readLastCaclMedalTime);
        } else {
            Calendar instance2 = Calendar.getInstance();
            instance2.add(Calendar.DAY_OF_YEAR, -2);
            instance.setTimeInMillis(instance2.getTimeInMillis());
        }
        SportDay sportDay = new SportDay(instance);
        SportDay l = m9055l();
//        C1270g c1270g = new C1270g();
//        while (l.compare(sportDay) >= 0) {
//            Summary b = m12210b(sportDay);
//            if (b != null && m12186a(sportDay, b)) {
//                c1270g.f6631h = b.getSleepStartTime();
//                c1270g.f = b.getSleepRiseTime();
//                GuliLog.tracePrintInfo(f7347b, "SleepSummary:" + c1270g.toString());
//                EventBus.getDefault().post(c1270g);
//            }
//            sportDay = sportDay.addDay(f7351h);
//        }
        Keeper.keepLastCaclMedalTime(Long.valueOf(Calendar.getInstance().getTimeInMillis()));
    }

    private void m12194w() {
//        C1271h c1271h = new C1271h();
//        ReportData reportData = new ReportData();
//        SportDay k = m9054k();
//        for (SportDay l = m9055l(); l.compare(k) >= 0; l = l.addDay(-1)) {
//            Summary b = m12210b(l);
//            if (b != null && b.getSteps() > 0) {
//                reportData.steps = b.getSteps() + reportData.steps;
//            }
//        }
//        c1271h.f6634h = (long) reportData.getSteps();
//        DaySportData g = m9052g(m9056m());
//        if (g != null) {
//            StepsInfo stepsInfo = g.getStepsInfo();
//            if (stepsInfo != null) {
//                c1271h.f6635i = stepsInfo.getStepsCount();
//            }
//        }
//        c1271h.f6636j = Keeper.readPersonInfo().getDaySportGoalSteps();
//        if (this.f7359A == null) {
//            this.f7359A = m12230i();
//        }
//        c1271h.f6638l = this.f7359A.getContinueDays();
//        c1271h.f = System.currentTimeMillis();
//        GuliLog.tracePrintInfo(f7347b, "step summary = " + c1271h);
//        EventBus.getDefault().post(c1271h);
    }

    private void m12195x() {
        m12196y();
        m12217c();
    }

    private void m12196y() {
        GuliLog.tracePrintInfo(f7347b, "clear.................................");
        this.f7363o.clear();
        this.f7364p.clear();
        this.f7365q = m9057n();
        this.f7366r = m9057n();
        this.f7367s = m9057n();
    }

    public int m12197a(String str, C1495q c1495q) {
        return this.f7362n.m8955a(str, c1495q);
    }

    public ReportData m12198a(SportDay sportDay, SportDay sportDay2) {
        GuliLog.tracePrintInfo(f7347b, "getContinueReachGoalReportData ==================== Step 1 =====================");
        ReportData c = m12189c(sportDay, sportDay2);
        GuliLog.tracePrintInfo(f7347b, "getContinueReachGoalReportData ==================== Step 2 ===================== ");
        return m12180a(c, this.f7372z, sportDay2);
    }

    public Summary m12199a(int i, SportDay sportDay) {
        // return i == f7353j ? C1689l.m13205a(f7358x).m13234b(sportDay) : m12215c(sportDay);
        return m12215c(sportDay);
    }

//    public DaySportData m12200a(int i, int i2, int i3) {
//        SportDay sportDay = new SportDay(i, i2, i3);
//        if (!(SyncedServerDataInfo.readInfoFromPref(f7350g).isSynced() && this.f7363o.containsKey(sportDay.getKey()))) {
//            GuliLog.m12370d(f7347b, "Not sync from server or database!!! loading...");
//            m9053i(sportDay);
//        }
//        return m9052g(sportDay);
//    }

    public DaySportData m12201a(String str) {
        return (DaySportData) this.f7363o.get(str);
    }

//    public SportDay m12202a(int i) {
//        return i == f7353j ? C1689l.m13205a(f7358x).m13240d() : this.f7365q;
//    }

    public ArrayList<BasicDateData> m12203a(C1495q c1495q) {
        return this.f7362n.m8961a(c1495q);
    }

    class C1453n extends AsyncTask<Void, Void, UserTotalSportData> {
        final /* synthetic */ C1468p f7373a;
        final /* synthetic */ DataManager f7374b;

        C1453n(DataManager c1448m, C1468p c1468p) {
            this.f7374b = c1448m;
            this.f7373a = c1468p;
        }

        protected UserTotalSportData m12242a(Void... voidArr) {
            return this.f7374b.m12222e(this.f7374b.m9055l());
        }

        protected void m12243a(UserTotalSportData userTotalSportData) {
            super.onPostExecute(userTotalSportData);
            this.f7373a.m12295a(userTotalSportData);
        }

        protected /* synthetic */ UserTotalSportData doInBackground(Void[] objArr) {
            return m12242a((Void[]) objArr);
        }

        protected /* synthetic */ void onPostExecute(UserTotalSportData obj) {
            m12243a((UserTotalSportData) obj);
        }
    }

    public void m12204a(int i, int i2) {
        SportDay sportDay = this.f7367s;
        if (i2 == 0) {
            sportDay = this.f7367s;
        } else if (i2 == f7351h) {
            sportDay = this.f7365q;
        } else if (i2 == f7352i) {
            sportDay = m9055l();
        }
        this.f7367s = sportDay.addDay(i);
    }

    public void m12205a(C1468p c1468p) {
        new C1453n(this, c1468p).execute(new Void[f7350g]);
    }

    public void m12206a(DaySportData daySportData) {
        this.f7363o.put(daySportData.getKey(), daySportData);
        SportDay sportDay = daySportData.getSportDay();
        if (this.f7365q.compare(sportDay) == f7351h) {
            this.f7365q = sportDay;
        }
    }

    public void m12207a(ArrayList<BasicDateData> arrayList, int i, C1495q c1495q) {
        GuliLog.tracePrintInfo(f7347b, "insertDatas.......................................0");
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            BasicDateData basicDateData = (BasicDateData) it.next();
            SportDay fromString = SportDay.fromString(basicDateData.date);
            GuliLog.tracePrintInfo(f7347b, "SD:" + fromString.getKey());
            DaySportData h = this.f7363o.containsKey(fromString.getKey()) ? (DaySportData) this.f7363o.get(fromString.getKey()) : m12228h(fromString);
            if (h != null) {
                GuliLog.tracePrintInfo(f7347b, "dayData not null.................");
                DaySportData daySportData = new DaySportData(fromString);
                daySportData.fromBinaryData(fromString, basicDateData.data);
                daySportData.merge(h);
                basicDateData.data = daySportData.getBinaryData();
            }
        }
        GuliLog.tracePrintInfo(f7347b, "insertDatas.......................................1");
//        this.f7362n.m8972a((ArrayList) arrayList, i, c1495q);
        GuliLog.tracePrintInfo(f7347b, "insertDatas.......................................2");
        m12195x();
    }

    public boolean m12208a(SportDay sportDay) {
        if (sportDay == null) {
            return f7348c;
        }
        Calendar calendar = sportDay.getCalendar();
        this.f7360d = SportDay.fromString(Keeper.readManualLazyDayAlgoStartDate());
        this.f7360d.getCalendar().set(Calendar.HOUR, f7350g);
        this.f7360d.getCalendar().set(Calendar.MINUTE, f7350g);
        boolean before = this.f7360d.getCalendar().before(calendar);
        GuliLog.tracePrintInfo(f7347b, "tempDay = " + sportDay + ", isAlgoritmManual = " + before + ", manual start algo: " + this.f7360d);
        return before;
    }

//    public BasicDateData m12209b(String str, C1495q c1495q) {
//        return this.f7362n.m8988g(str, c1495q);
//    }

    public Summary m12210b(SportDay sportDay) {
        return DeviceSource.hasBindBracelet() ? m12215c(sportDay) : DeviceSource.hasBindShoesDevice() ? null : m12215c(sportDay);
    }

    public DaySportData m12211b(int i, SportDay sportDay) {
        // return i == f7353j ? C1689l.m13205a(f7358x).m13229a(sportDay) :
        // DeviceSource.hasBindBracelet() ? sportDay == null ? new DaySportData(m9057n()) : (DaySportData) this.f7363o.get(sportDay.getKey()) : sportDay == null ? new DaySportData(m9057n()) : (DaySportData) this.f7363o.get(sportDay.getKey());
        return DeviceSource.hasBindBracelet() ? sportDay == null ? new DaySportData(m9057n()) : (DaySportData) this.f7363o.get(sportDay.getKey()) : sportDay == null ? new DaySportData(m9057n()) : (DaySportData) this.f7363o.get(sportDay.getKey());
    }
//
//    public SportDay m12212b(int i) {
//        return i == f7353j ? C1689l.m13205a(f7358x).m13242f() : m9057n();
//    }

    public void m12213b() {
        this.f7363o.clear();
        this.f7364p.clear();
        this.f7362n.m8982d();
        this.f7370w = new SyncedServerDataInfo(f7350g);
    }

//    public boolean m12214b(ArrayList<BasicDateData> arrayList, int i, C1495q c1495q) {
//        return this.f7362n.m8976b(arrayList, i, c1495q);
//    }

    public Summary m12215c(SportDay sportDay) {
        Summary summary = (Summary) this.f7364p.get(sportDay.getKey());
        if (summary == null) {
//            Object e = this.f7362n.m8984e(sportDay.getKey(), new C1495q(f7350g));
            String e = null;
            GuliLog.tracePrintInfo(f7347b, "Read Summary : " + sportDay + " , " + e);
            if (TextUtils.isEmpty(e)) {
                summary = new SummaryEmpty();
            } else {
                SummaryEntity summaryEntity = new SummaryEntity();
                try {
                    JSONObject jSONObject = new JSONObject(e);
                    int optInt = jSONObject.optInt(SportBaseInfo.VERSION, f7350g);
                    if (optInt >= f7351h) {
                        m12184a(summaryEntity, jSONObject, optInt);
                    } else {
                        m12183a(summaryEntity, jSONObject);
                    }
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
            this.f7364p.put(sportDay.getKey(), summary);
        }
        return summary;
    }

//    public SportDay m12216c(int i) {
//        return f7353j == i ? C1689l.m13205a(f7358x).m13238c() : this.f7367s;
//    }

    public void m12217c() {
        GuliLog.m12360b(f7347b, "in initDays");
        this.f7371y = new SportDay(2014, f7351h, f7351h);
//        String[] c = this.f7362n.m8981c();
        String[] c = null;
        if (c != null) {
            this.f7365q = SportDay.fromString(c[f7350g]);
            this.f7366r = SportDay.fromString(c[f7351h]);
            this.f7367s = m9055l();
            if (this.f7365q.compare(this.f7371y) < 0) {
                this.f7365q = this.f7371y;
            }
            if (this.f7366r.compare(this.f7367s) > 0) {
                this.f7366r = this.f7367s;
            }
            GuliLog.tracePrintInfo(f7347b, "localStartDay:" + this.f7365q + "\n" + "localStopDay:" + this.f7366r + "\n" + "curDay:" + this.f7367s);
        }
        this.f7370w = SyncedServerDataInfo.readInfoFromPref(f7350g);
        if (this.f7370w.isSyncedData()) {
            this.f7368t = SportDay.fromString(this.f7370w.getStartDate());
            this.f7369u = SportDay.fromString(this.f7370w.getStopDate());
        }
        GuliLog.tracePrintInfo(f7347b, "netStartDay:" + this.f7368t + "\n" + "netStopDay:" + this.f7369u + "\n" + "curDay:" + this.f7367s);
        GuliLog.m12360b(f7347b, "out initDays");
    }

    public ReportData m12218d() {
        int i = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
        SportDay sportDay = new SportDay();
        if (Utils.m8087m()) {
            i--;
        } else {
            if (i == f7351h) {
                i = 8;
            }
            i -= 2;
        }
        return m12187b(sportDay.addDay(-i), sportDay);
    }

    public SportDay m12219d(int i) {
        //return i == f7353j ? C1689l.m13205a(f7358x).m13242f() : new SportDay();
        return new SportDay();
    }

    public void m12220d(SportDay sportDay) {
        GuliLog.tracePrintInfo(f7347b, "Remove Summary : " + sportDay);
        if (sportDay != null && this.f7364p != null) {
            this.f7364p.remove(sportDay.getKey());
        }
    }

    public ReportData m12221e() {
        GuliLog.tracePrintInfo(f7347b, "in getLastWeekReportData");
        SportDay k = m9054k();
        SportDay l = m9055l();
        ReportData reportData = new ReportData();
        reportData.type = "SHARE_TYPE_LAST_WEEK";
        Calendar instance = Calendar.getInstance();
        int i = instance.get(f7349f);
        instance.add(f7354k, (i == f7351h ? -6 : 2 - i) - 7);
        SportDay sportDay = new SportDay(instance);
        instance.add(f7354k, f7355l);
        SportDay sportDay2 = new SportDay(instance);
        if (sportDay2.compare(k) < 0) {
            return reportData;
        }
        reportData.timeFrom = sportDay.getKey();
        reportData.timeTo = sportDay2.getKey();
        if (sportDay.compare(k) < 0) {
            sportDay = k;
        }
        k = sportDay2.compare(l) > 0 ? l : sportDay2;
        while (k.compare(sportDay) >= 0) {
            Summary b = m12210b(k);
            if (b != null && b.getSteps() > 0) {
                reportData.distance += b.getStepDistance();
                reportData.runDistance += b.getStepRunDistance();
                reportData.calories += b.getStepCalories();
                reportData.steps += b.getSteps();
                if (b.getSteps() > reportData.maxDateStep) {
                    reportData.maxDateStep = b.getSteps();
                    reportData.maxDateStr = k.getKey();
                }
            }
            k = k.addDay(-1);
        }
        GuliLog.tracePrintInfo(f7347b, "out getLastWeekReportData");
        return reportData;
    }

    public UserTotalSportData m12222e(SportDay sportDay) {
        UserTotalSportData userTotalSportData = new UserTotalSportData();
        SportDay sportDay2 = new SportDay(sportDay);
        SportDay k = m9054k();
        userTotalSportData.highestStepDay = k.toString();
        userTotalSportData.longestSleepDay = k.toString();
        int i = f7350g;
        while (sportDay.compare(k) >= 0) {
            Summary b = m12210b(sportDay);
            if (b == null) {
                sportDay = sportDay.addDay(-1);
            } else {
                int steps = b.getSteps();
                if (steps > 0) {
                    userTotalSportData.iDistance += b.getStepDistance();
                    userTotalSportData.iSteps += steps;
                    userTotalSportData.iTotalwearingdays += f7351h;
                    userTotalSportData.totalRunDist += b.getStepRunDistance();
                    if (steps > userTotalSportData.highestStep) {
                        userTotalSportData.highestStep = steps;
                        userTotalSportData.highestStepDay = sportDay.toString();
                    }
                }
                steps = b.getSleep();
                if (steps > 0) {
                    if (steps > userTotalSportData.longestSleepMin) {
                        userTotalSportData.longestSleepMin = steps;
                        userTotalSportData.longestSleepDay = sportDay.toString();
                    }
                    steps = b.getSleepDeepTime();
                    if (steps > userTotalSportData.longestSleepDeepMin) {
                        userTotalSportData.longestSleepDeepMin = steps;
                    }
                    steps = Utils.m7965a(b);
                    userTotalSportData.avgSleepStartTime += steps;
                    userTotalSportData.avgSleepEndTime = (Utils.m8029b(b) + steps) + userTotalSportData.avgSleepEndTime;
                    i += f7351h;
                }
                sportDay = sportDay.addDay(-1);
            }
        }
        userTotalSportData.startUseDay = k.toString();
        if (i > 0) {
            userTotalSportData.avgSleepStartTime /= i;
            userTotalSportData.avgSleepEndTime /= i;
        } else {
            userTotalSportData.avgSleepStartTime = f7350g;
            userTotalSportData.avgSleepEndTime = f7350g;
        }
        userTotalSportData.setReportData(m12198a(k, sportDay2));
        userTotalSportData.setWeekReportData(m12218d());
        if (userTotalSportData.iTotalwearingdays != 0) {
            userTotalSportData.iAverageSteps = userTotalSportData.iSteps / userTotalSportData.iTotalwearingdays;
        } else {
            userTotalSportData.iAverageSteps = f7350g;
        }
        GuliLog.tracePrintInfo(f7347b, "UserTotalSportData:\n" + userTotalSportData.toString());
        GuliLog.tracePrintInfo(f7347b, "out getUserTotalSportData ");
        return userTotalSportData;
    }

    public void m12223f() {
        m12194w();
        m12193v();
    }

    public void m12224f(SportDay sportDay) {
        this.f7367s = sportDay;
    }

    public ReportData m12225g() {
        GuliLog.tracePrintInfo(f7347b, "in getLastMonthReportData");
        ReportData reportData = new ReportData();
        reportData.type = "SHARE_TYPE_LAST_MONTH";
        Calendar instance = Calendar.getInstance();
        instance.add(f7352i, -1);
        instance.set(f7354k, f7351h);
        SportDay sportDay = new SportDay(instance);
        instance.set(f7354k, f7351h);
        instance.add(f7352i, f7351h);
        instance.add(f7354k, -1);
        SportDay sportDay2 = new SportDay(instance);
        SportDay k = m9054k();
        SportDay l = m9055l();
        if (sportDay2.compare(k) < 0) {
            return reportData;
        }
        reportData.timeFrom = sportDay.getKey();
        reportData.timeTo = sportDay2.getKey();
        if (sportDay.compare(k) >= 0) {
            k = sportDay;
        }
        sportDay = sportDay2.compare(l) > 0 ? l : sportDay2;
        while (sportDay.compare(k) >= 0) {
            DaySportData.Summary b = m12210b(sportDay);
            if (b != null && b.getSteps() > 0) {
                reportData.distance += b.getStepDistance();
                reportData.runDistance += b.getStepRunDistance();
                reportData.calories += b.getStepCalories();
                reportData.steps += b.getSteps();
                if (b.getSteps() > reportData.maxDateStep) {
                    reportData.maxDateStep = b.getSteps();
                    reportData.maxDateStr = sportDay.getKey();
                }
            }
            sportDay = sportDay.addDay(-1);
        }
        GuliLog.tracePrintInfo(f7347b, "out getLastMonthReportData");
        return reportData;
    }

    public DaySportData m9052g (SportDay sportDay) { //m12226g
        return DeviceSource.hasBindBracelet() ? sportDay == null ? new DaySportData(m9057n()) : (DaySportData) this.f7363o.get(sportDay.getKey()) : DeviceSource.hasBindShoesDevice() ? null : sportDay == null ? new DaySportData(m9057n()) : (DaySportData) this.f7363o.get(sportDay.getKey());
    }

//    public ReportData m12227h() {
//        GuliLog.tracePrintInfo(f7347b, "in getStepRecord");
//        ReportData reportData = new ReportData();
//        reportData.type = ShareListDelegateActivity.SHARE_TYPE_NEW_RECORD;
//        SportDay k = m9054k();
//        for (SportDay addDay = m9055l().addDay(-1); addDay.compare(k) >= 0; addDay = addDay.addDay(-1)) {
//            DaySportData.Summary b = m12210b(addDay);
//            if (b != null && b.getSteps() > 0 && b.getSteps() > reportData.steps) {
//                reportData.distance = b.getStepDistance();
//                reportData.calories = b.getStepCalories();
//                reportData.steps = b.getSteps();
//                reportData.maxDateStep = b.getSteps();
//                reportData.maxDateStr = addDay.getKey();
//            }
//        }
//        GuliLog.tracePrintInfo(f7347b, "out getStepRecord:" + reportData.steps);
//        return reportData;
//    }

    public DaySportData m12228h(SportDay sportDay) {
        // byte[] b = this.f7362n.m8978b(sportDay.getKey(), new C1495q());
        byte[] b = null;
        if (b == null || b.length == 0) {
            return null;
        }
        DaySportData daySportData = new DaySportData(sportDay);
        // byte[] c = this.f7362n.m8980c(sportDay.getKey(), new C1495q());
        byte[] c = null;
        if (c == null || c.length == 0) {
            daySportData.fromBinaryData(sportDay, b);
            return daySportData;
        }
        daySportData.fromBinaryWithHRData(sportDay, b, c);
        return daySportData;
    }

    public synchronized int m9053i (SportDay sportDay) { // m12229i
        int k = 0;
//        k = DeviceSource.hasBindBracelet() ? m12191k(sportDay) : DeviceSource.hasBindShoesDevice() ? C1689l.m13205a(f7358x).m13237c(sportDay) : m12191k(sportDay);
        return k;
    }

    public ReportData m12230i() {
        this.f7359A = m12198a(m9054k(), m9055l());
        return this.f7359A;
    }

    public boolean m12231j() {
        boolean z;
        SportDay k = m9054k();
        for (SportDay l = m9055l(); l.compare(k) >= 0; l = l.addDay(-1)) {
            if (m12210b(l).getSleep() > 0) {
                z = true;
                GuliLog.tracePrintInfo(f7347b, "Check has sleep summary : true");
                break;
            }
        }
        z = f7348c;
        if (!z) {
            GuliLog.tracePrintInfo(f7347b, "Check has sleep summary : false");
        }
        return z;
    }

    public SportDay m9054k() {  //m12232k
//        return DeviceSource.hasBindBracelet() ? this.f7365q : DeviceSource.hasBindShoesDevice() ? C1689l.m13205a(f7358x).m13240d() : this.f7365q;
        return DeviceSource.hasBindBracelet() ? this.f7365q : DeviceSource.hasBindShoesDevice() ? null : this.f7365q;
    }

    public SportDay m9055l() {  // m12233l
        //return DeviceSource.hasBindBracelet() ? m9057n() : DeviceSource.hasBindShoesDevice() ? C1689l.m13205a(f7358x).m13242f() : m9057n();
        return DeviceSource.hasBindBracelet() ? m9057n() : DeviceSource.hasBindShoesDevice() ? null : m9057n();
    }

    public SportDay m9056m() { // m12234m
        //return DeviceSource.hasBindBracelet() ? this.f7367s : DeviceSource.hasBindShoesDevice() ? C1689l.m13205a(f7358x).m13238c() : this.f7367s;
        return DeviceSource.hasBindBracelet() ? this.f7367s : DeviceSource.hasBindShoesDevice() ? null : this.f7367s;
    }

    public SportDay m9057n() {  //m12235n
        // return DeviceSource.hasBindBracelet() ? new SportDay() : DeviceSource.hasBindShoesDevice() ? C1689l.m13205a(f7358x).m13242f() : new SportDay();
        return DeviceSource.hasBindBracelet() ? new SportDay() : DeviceSource.hasBindShoesDevice() ? null : new SportDay();
    }

    public synchronized void m12236o() {
        GuliLog.m12370d(f7347b, "in analysis");
        for (Map.Entry entry : this.f7363o.entrySet()) {
            DaySportData daySportData = (DaySportData) entry.getValue();
            SportDay sportDay = daySportData.getSportDay();
            GuliLog.tracePrintInfo(f7347b, "in analysis entry= " + entry);
            if (daySportData != null && daySportData.isNeedPostProcess() && daySportData.isLocalNeedSync()) {
                SportDay addDay = sportDay.addDay(-1);
                DaySportData g = m9052g(addDay);
                DaySportData h = g == null ? m12228h(addDay) : g;
                SportDay addDay2 = sportDay.addDay(f7351h);
                g = m9052g(addDay2);
                if (g == null) {
                    g = m12228h(addDay2);
                }
                m12185a(h, daySportData, g);
                GuliLog.tracePrintInfo(f7347b, "in analysis dataPostProcess= " + daySportData);
                m12220d(sportDay);
            }
        }
        GuliLog.m12370d(f7347b, "out analysis");
    }

    public void m12237p() {
        GuliLog.m12360b(f7347b, "in saveToDb");
//        C3910h f = C3844a.m25161f();
//        boolean a = f != null ? f.m25440a() : f7348c;
//        PersonInfo readPersonInfo = Keeper.readPersonInfo();
//        for (Entry value : this.f7363o.entrySet()) {
//            DaySportData daySportData = (DaySportData) value.getValue();
//            if (daySportData.isLocalNeedSync()) {
//                GuliLog.m12370d(f7347b, "saveToDb:" + daySportData.getKey());
//                if (a) {
//                    GuliLog.m12370d(f7347b, "MiLi 1S's data saveToDb");
//                    this.f7362n.m8970a(daySportData.getKey(), daySportData.getBinaryData(), daySportData.getSummary(readPersonInfo.getDaySportGoalSteps()), daySportData.getIndexS(), m12241t(), daySportData.getBinaryHRData(this.f7362n.m8980c(daySportData.getKey(), m12241t())), daySportData.getHRSummary(this.f7362n.m8986f(daySportData.getKey(), m12241t())));
//                } else {
//                    GuliLog.m12370d(f7347b, "MiLi 1's data saveToDb");
//                    this.f7362n.m8969a(daySportData.getKey(), daySportData.getBinaryData(), daySportData.getSummary(readPersonInfo.getDaySportGoalSteps()), daySportData.getIndexS(), m12241t());
//                }
//                daySportData.setLocalNeedSync(f7348c);
//            }
//        }
        GuliLog.m12360b(f7347b, "out saveToDb");
    }

    public int m12238q() {
        int b = Utils.m8030b(Calendar.getInstance());
        Calendar instance = Calendar.getInstance();
        instance.add(f7354k, 1 - b);
        instance.add(f7354k, -3);
        SportDay sportDay = new SportDay(instance);
        SportDay addDay = sportDay.addDay(-4);
        long j = 0;
        b = f7350g;
        for (SportDay sportDay2 = sportDay; sportDay2.compare(addDay) >= 0; sportDay2 = sportDay2.addDay(-1)) {
            Summary b2 = m12210b(sportDay2);
            if (b2 != null && b2.getSleep() > 0) {
                j += (long) (Utils.m8029b(b2) + Utils.m7965a(b2));
                b += f7351h;
            }
        }
        return b > 0 ? (int) (j / ((long) b)) : f7350g;
    }

    public int m12239r() {
        return (!DeviceSource.hasBindBracelet() && DeviceSource.hasBindShoesDevice()) ? f7353j : f7350g;
    }

    public void m12240s() {
        if (DeviceSource.hasBindBracelet()) {
            SportDay n = m9057n();
            DaySportData g = m9052g(n);
            m12220d(n);
            if (g != null) {
                g.setNeedSync(true);
            }
            m12237p();
        }
        if (DeviceSource.hasBindShoesDevice()) {
//            C1689l.m13205a(f7358x).m13246j();
        }
    }
//
//    public C1495q m12241t() {
//        C3910h f = C3844a.m25161f();
//        return f == null ? new C1495q() : f.m25441b() ? new C1495q(f7350g, f7354k) : f.m25440a() ? new C1495q(f7350g, f7346a) : DeviceSource.hasBindSensorHub() ? new C1495q(f7350g, f7352i) : new C1495q();
//    }
}
